#pragma once
namespace xy {
	template<class iterator, class Ref, class Ptr>
	struct reverse_iterator {
		iterator _it;

		typedef reverse_iterator<iterator, Ref, Ptr> self;
		reverse_iterator(iterator it)
			:_it(it) {}

		Ref operator*() {
			iterator tmp = _it;
			return *(--tmp);
		}
		
		self& operator++() {
			--_it;
			return *this;
		}

		self operator++(int) {
			self tmp = *this;
			--_it;
			return tmp;
		}

		self& operator--() {
			++_it;
			return *this;
		}

		self operator--(int) {
			self tmp = *this;
			++_it;
			return tmp;
		}

		Ptr operator->() {
			return &(operator*());
		}

		bool operator!=(const self& tmp) {
			return _it != tmp._it;
		}
	};
}